package sg.edu.nus.iss.phoenix.utils;

import java.text.DateFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;

public class CommonUtils {

	public static Date getCurrentDate() {
		Calendar cal = Calendar.getInstance();
		return cal.getTime();
		
	}

	public static Date convertStrtoDate(String str_date) {
		try {
			DateFormat formatter;
			Date date;
			formatter = new SimpleDateFormat("yyyy-MM-dd");
			date = (Date) formatter.parse(str_date);
			return date;
		} catch (ParseException e) {
			System.out.println("Exception :" + e);
			return getCurrentDate();
		}
	}
	
	 public static java.sql.Date changeToSQLDate(Date date) {
   	  java.util.Date utilDate = new java.util.Date();
   	  java.sql.Date sqlDate = new java.sql.Date(date.getTime());
   	   return sqlDate;		
	}
	 
	
	
}
